/**
 * 
 */
package com.vector.ding.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.vector.ding.context.AuthContext;
import com.vector.ding.safe.IUser;

/**
 * @author vector
 *
 */
@Controller
public class IndexController {
	
	//private static final Logger logger = LoggerFactory.getLogger(IndexController.class);

	/**
	 * 登录操作
	 * @return
	 */
	@RequestMapping(value = "/index.do", method = RequestMethod.GET)
	public ModelAndView index() {
		try {
			IUser user = AuthContext.getCurrentUser();
			ModelAndView mv = new ModelAndView("index_bui");
			mv.addObject("loginName", user.getLoginName());
			mv.addObject("realName", user.getRealName());
			mv.addObject("isAdmin", user.getLoginName().equals("admin"));
			mv.addObject("userId", user.getId());
			return mv;
		} catch (Exception e) {
			// jump to login page
			return new ModelAndView("login");
		}
	}
	
}
